package com.salt.config;

import com.salt.interceptor.AuthInterceptor;
import com.salt.service.UserService;
import com.salt.util.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private JwtUtil jwtUtil;
    @Autowired
    private UserService userService;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthInterceptor(jwtUtil, userService))
                .addPathPatterns("/api/**") // 需要拦截的路径
                .excludePathPatterns("/api/user/login","/api/material/materials", "/api/user/register", "/api/user/send-code", "/api/user/reset-password","/api/taobao/materials","/api/material/sync/itemId","/api/material/itemId","/api/material/promotion-link-new","/api/taobao/material1","/api/taobao/material2"); // 不拦截登录注册
    }
}